home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / dvipage / dvipage.h < prev    next >
C/C++ Source or Header  |  1992-05-11  |  9KB  |  401 lines

  1. /*
  2.  * dvipage: DVI Previewer Program for Suns
  3.  *
  4.  * Neil Hunt (hunt@spar.slb.com)
  5.  *
  6.  * This program is based, in part, upon the program dvisun,
  7.  * distributed by the UnixTeX group, extensively modified by
  8.  * Neil Hunt at the Schlumberger Palo Alto Research Laboratories
  9.  * of Schlumberger Technologies, Inc.
  10.  *
  11.  * From the dvisun manual page entry:
  12.  *    Mark Senn wrote the early versions of [dvisun] for the
  13.  *    BBN BitGraph. Stephan Bechtolsheim, Bob Brown, Richard
  14.  *    Furuta, James Schaad and Robert Wells improved it. Norm
  15.  *    Hutchinson ported the program to the Sun. Further bug fixes
  16.  *    by Rafael Bracho at Schlumberger.
  17.  *
  18.  * Copyright (c) 1988 Schlumberger Technologies, Inc 1988.
  19.  * Anyone can use this software in any manner they choose,
  20.  * including modification and redistribution, provided they make
  21.  * no charge for it, and these conditions remain unchanged.
  22.  *
  23.  * This program is distributed as is, with all faults (if any), and
  24.  * without any warranty. No author or distributor accepts responsibility
  25.  * to anyone for the consequences of using it, or for whether it serves any
  26.  * particular purpose at all, or any other reason.
  27.  *
  28.  * $Log:    dvipage.h,v $
  29.  * Revision 1.2  88/12/15  17:22:36  hunt
  30.  * Reduced MAXOPEN to 12; leaves enough fds for popups and prompts in worst
  31.  * case: complete set of fonts, message window and popup window.
  32.  * 
  33.  * Revision 1.1  88/11/28  18:42:06  hunt
  34.  * Initial revision
  35.  * 
  36.  */
  37.  
  38. /*
  39.  * Switches and flags;
  40.  * ==================
  41.  *
  42.  * Some of these constants will be customised for different installations.
  43.  */
  44.  
  45. /*
  46.  * Define USEGLOBALMAG to see effect of mag changes in previewer;
  47.  * Best left commented out.
  48.  */
  49. /* #define USEGLOBALMAG        1    /* Use dvi global magnification ??? */
  50.  
  51. /*
  52.  * FONT_PATH is the environment variable searched for a font path spec.
  53.  * FONT_AREA is the default font path; a colon separated list of possible
  54.  *    directories in which pxl and gf files reside.
  55.  */
  56. #define FONT_PATH        "FONT_PATH"
  57.  
  58. #ifndef FONT_AREA
  59. #ifdef sparc
  60. #define FONT_AREA \
  61.   "/usr/local/lib/tex/fonts/pkb:/usr/local/lib/tex/fonts/pk"
  62. #else !sparc
  63. #define FONT_AREA \
  64.   "/usr/local/lib/tex/fonts/pkb:/usr/local/lib/tex/fonts/pk"
  65. #endif sparc
  66. #endif  FONT_AREA
  67.  
  68. /*
  69.  * These constants set flag defaults; if the flag is 0, that type of
  70.  *    font file will not be read.
  71.  */
  72. #define USE_GF            1
  73. #define USE_PXL            1
  74. #define USE_PK            1
  75.  
  76. /*
  77.  * Define a command which will print the whole document.
  78.  */
  79. #ifndef PRINT_SPOOLER
  80. #define PRINT_SPOOLER        "lpr -d %s >/dev/null 2>/dev/null"
  81. #endif  PRINT_SPOOLER
  82.  
  83. /*
  84.  * Define a command which will print the specified page of the document.
  85.  */
  86. #ifndef PRINT_PAGE_SPOOLER
  87. #define PRINT_PAGE_SPOOLER \
  88.     "texpagefilter -f %d -t %d %s | lpr -d >/dev/null 2>/dev/null"
  89. #endif    PRINT_PAGE_SPOOLER
  90.  
  91. /*
  92.  * The default size of page which will be used
  93.  */
  94. #define PAGE_WIDTH        (8.3)    /* Inches */
  95. #define PAGE_HEIGHT        (11.7)    /* Inches */
  96.  
  97. /*
  98.  * The default origin on the paper; this corresponds to the
  99.  * normal TeX standard; change it only if your printer or dvi processor is
  100.  * broken and you must match
  101.  */
  102. #define DEFAULT_ORIGIN_X    (1)    /* inches */
  103. #define DEFAULT_ORIGIN_Y    (1)    /* inches */
  104.  
  105. /*
  106.  * default starting display... makes better use of screen.
  107.  */
  108.  
  109. #define DEFAULT_START_X        (0)     /* inches */
  110. #define DEFAULT_START_Y        (0)     /* inches */
  111.  
  112. /*
  113.  * These are the defaults for resolution and sampling factors
  114.  * of fonts for colour and mono screens.
  115.  */
  116. #define DEFAULT_MONO_RES    118
  117. #define DEFAULT_COLOUR_RES    300
  118.  
  119. #define DEFAULT_MONO_SAMPLING    1    /* Must be 1 */
  120. #define DEFAULT_COLOUR_SAMPLING    4
  121.  
  122. /*
  123.  * This is the default magnifier size and border width.
  124.  */
  125. #define DEFAULT_MAG_SIZE_X    (256)
  126. #define DEFAULT_MAG_SIZE_Y    (128)
  127. #define DEFAULT_MAG_BORDER    (2)
  128.  
  129. /*
  130.  * Some limits in the program.  Change for extraordinary TeX files.
  131.  */
  132. #ifdef NOFILE
  133. #define MAXOPEN            NOFILE-6 /* leave room for stdio, */
  134.                      /*  window, message,popup */
  135. #else
  136. #define MAXOPEN            12    /* Max number of open font files. */
  137. #endif
  138. #define STACKSIZE        100    /* dvi stack max length */
  139. #define STRSIZE            MAXPATHLEN    /* Max string length */
  140. #define MAX_SHEETS        512    /* Pages remembered in table */
  141.  
  142. /*
  143.  * This identifies the version number of the previewer.
  144.  */
  145. #define DVIPAGE_LABEL        "DVI Previewer 3.0"    /* Frame label */
  146.  
  147. /*
  148.  * Standard definitions.
  149.  * ====================
  150.  */
  151.  
  152. #ifndef _TYPES_
  153. typedef unsigned int        uint;
  154. typedef unsigned short        ushort;
  155. #endif _TYPES_
  156. typedef unsigned char        uchar;
  157. #ifdef bool
  158. #undef bool
  159. #endif bool
  160. typedef unsigned int        bool;
  161.  
  162. #define DEL            '\177'
  163. #define ESC            '\033'
  164. #define Control(c)        ((c) - 0x40)
  165.  
  166. #define A_ARG            0
  167. #define A_END            (-1)
  168.  
  169. #define forward            extern
  170.  
  171. #define Range(min, x, max)    (((x) < (min))? \
  172.                  (min) : (((x) > (max))? (max) : (x)) \
  173.                 )
  174.  
  175. #define MAXINT            2147483647
  176. #define NEGMAXINT        (-2147483648)
  177.  
  178. #ifndef TRUE
  179. #define TRUE            1
  180. #define FALSE            0
  181. #endif  TRUE
  182.  
  183. /*
  184.  * System wide constants.
  185.  * =====================
  186.  */
  187.  
  188. #define    NONEXISTENT        (-1)    /* Offset when font file not found */
  189. #define NO_FILE            ((FILE *)-1)
  190.  
  191. #define NFNTCHARS              256
  192.  
  193. #define PXLID            1001
  194.  
  195. #define DVIFORMAT        2
  196.  
  197. #define SKIP            TRUE    /* Flags for process_page() */
  198. #define RASTERISE        FALSE
  199.  
  200. #define DEBUG_FONTS        1
  201. #define DEBUG_CHARS        2
  202. #define DEBUG_PRINTER        4
  203. #define DEBUG_IMSIZE        8
  204. #define DEBUG_SHEET        16
  205. #define DEBUG_MAGNIFY        32
  206.  
  207. #define BAD_PAGE        NEGMAXINT
  208. #define LAST_PAGE        MAXINT
  209.  
  210. /*
  211.  * Macros:
  212.  *    return rounded number of pixels
  213.  */
  214.  
  215. #define Pix_round(x, conv)    ((int)(((x) + ((conv) >> 1)) / (conv)))
  216.  
  217. /*
  218.  * Data Structures
  219.  * ===============
  220.  */
  221.  
  222. /*
  223.  * Character information.
  224.  *    Width in pixels.
  225.  *    Height in pixels.
  226.  *    X offset in pixels.
  227.  *    Y offset in pixels.
  228.  *    Location of bits
  229.  *        Flag for bits have been loaded into memory.
  230.  *            offset to position in file.
  231.  *            pointer to the bits.
  232.  *    width.
  233.  */
  234.  
  235. struct char_entry
  236. {
  237.     ushort        width;
  238.     ushort        height;
  239.     short        xOffset;
  240.     short        yOffset;
  241.     struct
  242.     {
  243.         int        isloaded;
  244.         union
  245.         {
  246.             int        fileOffset;
  247.             struct pixrect    *pixrectptr;
  248.         } address;
  249.         int        flags;
  250.     } where;
  251.     int        tfmw;
  252. };
  253.  
  254. /*
  255.  * Font information.
  256.  */
  257.  
  258. struct font_entry
  259. {
  260.     struct font_entry *next;    /* Linked list of fonts in use. */
  261.     FILE        *font_file_fd;  /* FP (0 if not open, -1 if unavail) */
  262.     int        use_count;    /* Count of number of uses of font */
  263.     int        k;        /* Internal font descriptor */
  264.     int        c;        /* checksum from DVI file */
  265.     int        s;        /* space size from DVI file */
  266.     int        d;        /* design size from DVI file */
  267.     int        a;        /* area length for font name */
  268.     int        l;        /* device length */
  269.     char        n[STRSIZE];    /* FNT_DEF command parameters  */
  270.     int        font_space;    /* computed from FNT_DEF s parameter */
  271.     int        font_gf_mag;    /* computed from s and d parameters */
  272.     int        font_pxl_mag;    /* computed from s and d parameters */
  273.     char        psname[STRSIZE];/* ps name of font file */
  274.     char        name[STRSIZE];    /* full name of font file */
  275.     int        type;        /* PXL or GF */
  276.     int        magnification;    /* magnification read from font file */
  277.     int        designsize;    /* design size read from font file */
  278.     struct char_entry ch[NFNTCHARS];/* character information */
  279. };
  280.  
  281. #define TYPE_PXL    1
  282. #define TYPE_GF        2
  283. #define TYPE_PK        3
  284.  
  285. /*
  286.  * mem_pixrect:
  287.  *    A statically allocatable pixrect structure.
  288.  *    Contains the pixrect data and the mpr_data.
  289.  */
  290.  
  291. struct mem_pixrect
  292. {
  293.     struct pixrect        mpr_pr;
  294.     struct mpr_data        mpr_data;
  295. };
  296.  
  297. /*
  298.  * Globals.
  299.  * =======
  300.  */
  301.  
  302. extern struct font_entry *fontptr;
  303. extern struct font_entry *hfontptr;
  304.  
  305. extern bool silent;
  306.  
  307. extern char pathname[STRSIZE];
  308. extern char directory[STRSIZE];
  309. extern char filename[STRSIZE];
  310.  
  311. extern char *font_path;
  312. extern bool use_gf;
  313. extern bool use_pxl;
  314. extern bool use_pk;
  315.  
  316. extern FILE *dvifp;
  317.  
  318. extern int resolution;
  319. extern int sampling;
  320. extern bool mono;
  321.  
  322. extern struct mem_pixrect page_mpr;
  323. extern struct pixrect *page_pr;
  324. extern struct mem_pixrect sample_mpr;
  325. extern struct pixrect *sample_pr;
  326.  
  327. extern int verbose;
  328.  
  329. /*
  330.  * External Functions.
  331.  * ==================
  332.  */
  333.  
  334. extern int            abs();
  335. extern char *            getenv();
  336. extern double            atof();
  337.  
  338. /*
  339.  * Interfaces.
  340.  * ==========
  341.  */
  342.  
  343. /*
  344.  * In sample.c:
  345.  */
  346. extern void            pw_cover();
  347. extern void            pw_rect();
  348. extern void            pr_rect();
  349. forward struct pixrect *    pr_alloc();
  350. forward struct pixrect *    pr_free();
  351. forward struct pixrect *    pr_check();
  352. forward struct pixrect *    pr_link();
  353. extern void            sample_page();
  354. forward struct pixrect *    pr_sample_4();
  355. forward struct pixrect *    pr_sample_34();
  356. forward struct pixrect *    pr_sample_3();
  357. forward struct pixrect *    pr_sample_2();
  358. extern void            make_cmap();
  359. forward void            pw_cover();
  360. forward void            pr_rect();
  361. forward void            pw_rect();
  362.  
  363. /*
  364.  * In fonts.c:
  365.  */
  366. extern bool            get_font_def();
  367. extern void            skip_font_def();
  368. extern bool            read_font_def();
  369. extern void            close_fonts();
  370. extern bool            load_char();
  371.  
  372. /*
  373.  * In findfile.c:
  374.  */
  375. extern bool            find_font_file();
  376.  
  377. /*
  378.  * In message.c:
  379.  */
  380. extern void            message();
  381. extern bool            strings_prompt();
  382. extern bool            integers_prompt();
  383. extern bool            doubles_prompt();
  384.  
  385. /*
  386.  * In utils.c:
  387.  */
  388. forward unsigned int        get_unsigned();
  389. forward int            get_signed();
  390. forward double            actual_factor();
  391. forward int            do_convert();
  392.  
  393. /*
  394.  * In args.c:
  395.  */
  396. extern char *            a_prog_name;
  397. extern char            a_next();
  398. extern char *            a_arg();
  399. extern int            a_integer();
  400. extern double            a_number();
  401.